package Server.logic;



import java.util.ArrayList;

import junit.framework.Assert;
import junit.framework.TestCase;

import org.junit.Before;
import org.junit.Test;

import Server.DataBase.Lesson;
import Server.DataBase.Reg;
import Server.DataBase.Student;
import Server.logic.Statistics;

public class StatisticsTest extends TestCase  {
	private ArrayList<Reg> r80,r85,r90;
	private ArrayList<Student> s;
	private ArrayList<Lesson> l;
	Statistics st;
	
	@Before
	public void setUp() throws Exception {
		st = new Statistics();
		r80= new ArrayList<Reg>();
		r80.add(new Reg(0,0,0,0,0,90));
		r80.add(new Reg(0,0,0,0,0,70));
		r85= new ArrayList<Reg>();
		r85.add(new Reg(0,0,0,0,0,90));
		r85.add(new Reg(0,0,0,0,0,80));
		r90= new ArrayList<Reg>();
		r90.add(new Reg(0,0,0,0,0,100));
		r90.add(new Reg(0,0,0,0,0,80));
		s = new ArrayList<Student>();
		s.add(new Student(0, "", "", 0, 0, "", "", 0, r80));
		s.add(new Student(0, "", "", 0, 0, "", "", 0, r85));
		l = new ArrayList<Lesson>();
		l.add(new Lesson(0,null,null,null,0,r85));
		l.add(new Lesson(0,null,null,null,0,r90));
	}

	@Test
	public void testAvgStudents() {
		Assert.assertEquals(82.5, st.avgStudents(s), 0);
	}

	@Test
	public void testAvgReg() {
		Assert.assertEquals(80, st.avgReg(r80), 0);
		Assert.assertEquals(85, st.avgReg(r85), 0);
		Assert.assertEquals(90, st.avgReg(r90), 0);
	}

	@Test
	public void testAvgLessons() {
		Assert.assertEquals(87.5, st.avgLessons(l), 0);
	}

}
